<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" 
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - 校园二手书交易平台</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <style>
        .register-card {
            background-color: #f8f9fa;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-top: 50px;
        }
        .footer {
            background-color: #343a40;
            color: white;
            padding: 30px 0;
            margin-top: 50px;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" th:href="@{/}">校园二手书交易平台</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/}"><i class="fas fa-home"></i> 首页</a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/login}"><i class="fas fa-sign-in-alt"></i> 登录</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" th:href="@{/user/register}"><i class="fas fa-user-plus"></i> 注册</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 注册表单区域 -->
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="register-card">
                    <h2 class="text-center mb-4">用户注册</h2>
                    
                    <!-- 错误消息显示 -->
                    <div th:if="${message}" th:class="'alert ' + ${messageType}" role="alert">
                        <span th:text="${message}"></span>
                    </div>
                    
                    <form th:action="@{/user/register}" method="post">
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" required
                                   placeholder="请输入用户名">
                        </div>
                        
                        <div class="form-group">
                            <label for="realName">真实姓名</label>
                            <input type="text" class="form-control" id="realName" name="realName" required
                                   placeholder="请输入真实姓名">
                        </div>
                        
                        <div class="form-group">
                            <label for="password">密码</label>
                            <input type="password" class="form-control" id="password" name="password" required
                                   placeholder="请输入密码">
                        </div>
                        
                        <button type="submit" class="btn btn-primary btn-block">注册</button>
                        
                        <div class="text-center mt-3">
                            已有账号？ <a th:href="@{/user/login}">立即登录</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- JavaScript -->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // 密码显示/隐藏功能
        $('.toggle-password').click(function() {
            const passwordInput = $(this).closest('.input-group').find('input');
            const icon = $(this).find('i');
            
            if (passwordInput.attr('type') === 'password') {
                passwordInput.attr('type', 'text');
                icon.removeClass('fa-eye').addClass('fa-eye-slash');
            } else {
                passwordInput.attr('type', 'password');
                icon.removeClass('fa-eye-slash').addClass('fa-eye');
            }
        });
    </script>
</body>
</html> 